package com.muy.redis.view.window.redis.enums;

import com.google.common.collect.Maps;
import com.intellij.ui.SimpleTextAttributes;
import com.muy.redis.utils.GuiUtils;

import javax.swing.*;
import java.awt.*;
import java.util.Map;

/**
 * @date 2021/8/19 8:14 下午
 */
public enum RedisValueTypeEnum {
    String("string", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new Color(170,170,255)), GuiUtils.STRING),
    List("list", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new Color(170,255,255)), GuiUtils.LIST),
    Set("set", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new Color(255,255,86)), GuiUtils.SET),
    Zset("zset", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new Color(170,255,170)), GuiUtils.ZSET),
    Hash("hash", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new Color(255,170,255)), GuiUtils.HASH),
    ;

    public static Map<String, RedisValueTypeEnum> redisValueTypeEnumMap = Maps.newHashMap();
    static {
        for(RedisValueTypeEnum redisValueTypeEnum : RedisValueTypeEnum.values()){
            redisValueTypeEnumMap.put(redisValueTypeEnum.redisValue, redisValueTypeEnum);
        }
    }

    private String redisValue;
    private SimpleTextAttributes simpleTextAttributes;
    private Icon icon;
    RedisValueTypeEnum(String redisValue, SimpleTextAttributes simpleTextAttributes, Icon icon){
        this.redisValue = redisValue;
        this.simpleTextAttributes = simpleTextAttributes;
        this.icon = icon;
    }

    public static RedisValueTypeEnum typeEnum(String redisValue){
        return redisValueTypeEnumMap.get(redisValue);
    }

    public java.lang.String getRedisValue() {
        return redisValue;
    }

    public SimpleTextAttributes getSimpleTextAttributes() {
        return simpleTextAttributes;
    }

    public Icon getIcon() {
        return icon;
    }
}
